balance = 1000  # 初始余额
while True:
    print("\n=== ATM模拟系统 ===")
    print("1. 查询余额")
    print("2. 存款")
    print("3. 取款")
    print("4. 退出")
    choice = input("请选择操作(1-4): ")

    if choice == "1":
        print(f"当前余额: ￥{balance:.2f}")
    elif choice == "2":
        amount = float(input("输入存款金额: "))
        if amount > 0:
            balance += amount
            print(f"存款成功！余额: ￥{balance:.2f}")
        else:
            print("金额必须大于0！")
    elif choice == "3":
        amount = float(input("输入取款金额: "))
        if amount > balance:
            print("余额不足！")
        elif amount <= 0:
            print("金额无效！")
        else:
            balance -= amount
            print(f"取款成功！余额: ￥{balance:.2f}")
    elif choice == "4":
        print("感谢使用，再见！")
        break
    else:
        print("无效输入，请重新选择！")







while True:
    score = input("请输入成绩(0-100，输入q退出): ")
    if score.lower() == 'q':
        break

    try:
        score = float(score)
        if 0 <= score <= 100:
            if score >= 90:
                grade = "A"
            elif score >= 80:
                grade = "B"
            elif score >= 70:
                grade = "C"
            elif score >= 60:
                grade = "D"
            else:
                grade = "F"
            print(f"成绩等级: {grade}")
        else:
            print("成绩必须在0-100之间！")
    except ValueError:
        print("请输入数字！")








# 判断单个数字是否为素数
def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True







# 综合应用：输出指定范围内的素数
start = int(input("起始值: "))
end = int(input("结束值: "))
print(f"{start}到{end}的素数:")
for num in range(start, end+1):
    if is_prime(num):
        print(num, end=" ")

import random

words = ["python", "java", "javascript", "html", "css"]
secret_word = random.choice(words)
max_attempts = 5
hint = "_" * len(secret_word)

for attempt in range(1, max_attempts + 1):
    print(f"\n第{attempt}次尝试 | 当前提示: {hint}")
    guess = input("猜一个字母: ").lower()

    if len(guess) != 1 or not guess.isalpha():
        print("请输入单个字母！")
        continue

    new_hint = ""
    correct_guess = False
    for i in range(len(secret_word)):
        if secret_word[i] == guess:
            new_hint += guess
            correct_guess = True
        else:
            new_hint += hint[i]
    hint = new_hint

    if correct_guess:
        print("猜对了！")
    else:
        print("猜错了！")

    if "_" not in hint:
        print(f"恭喜！你猜中了单词: {secret_word}")
        break
else:
    print(f"游戏结束！正确答案是: {secret_word}")















def calculate(a, b, op):
    if op == "+":
        return a + b
    elif op == "-":
        return a - b
    elif op == "*":
        return a * b
    elif op == "/":
        return a / b if b != 0 else None
    else:
        return None


print("=== 连续计算器 ===")
print("输入格式: 数字 运算符 数字 (如: 3 + 5)")
print("输入'quit'退出")

while True:
    user_input = input("\n请输入表达式: ").strip()
    if user_input.lower() == 'quit':
        break

    parts = user_input.split()
    if len(parts) != 3:
        print("格式错误！")
        continue

    try:
        num1 = float(parts[0])
        operator = parts[1]
        num2 = float(parts[2])

        result = calculate(num1, num2, operator)
        if result is None:
            print("无效运算符或除数为零！")
        else:
            print(f"结果: {result:.2f}")
    except ValueError:
        print("请输入有效数字！")









